﻿/*
 * Copyright © 2025−2026 WEI.ZHOU (Willis) (Chengdu). All rights reserved.
 *
 * THIS SOURCE CODE IS PROPRIETARY AND CONFIDENTIAL.
 * It is the exclusive property of WEI.ZHOU (Willis) and may not be
 * used, copied, distributed, or disclosed outside of WEI.ZHOU (Willis)
 * without express written permission.
 *
 * This code is provided to WEI.ZHOU (Willis) under a limited,
 * non-transferable internal license, and is for use only with the author's
 * approved purposes. No external license is granted or implied.
 *
 * Any unauthorized use, reproduction, or distribution is strictly prohibited
 * and may result in severe civil and criminal penalties.
 */

using Aore.Core.BaseModels;
using Aore.Core.LogUtils;
using Aore.IService.User;
using Microsoft.AspNetCore.Mvc;
using ILogger = NLog.ILogger;

namespace Aore.WebAPI.Controllers;

[ApiController]
[Route("[controller]")]
[ApiExplorerSettings(GroupName = nameof(ApiVersion.v1))]
public class UserController:ControllerBase
{
  private readonly ILogger _logger;
  
  private readonly IUserService _userService;
  
  private readonly IConfiguration _configuration;

  public UserController(IUserService userService, Func<Type, ILogger> loggerFactory, IConfiguration configuration)
  {
    _userService = userService;
    _logger = loggerFactory(typeof(UserController));
    _configuration = configuration;
  }

  /// <summary>
  /// 获取用户信息
  /// </summary>
  /// <returns></returns>
  [HttpGet]
  public ApiResult GetList()
  {
    var data = _userService.GetUsers();
    
    //_logger.Info("获取用户信息成功");
    
    //AppLog.Error("获取用户失败", new Exception("获取用户失败"));
    
    return new ApiResult()
    {
      Success = true,
      Message = "成功",
      Code = _configuration["AllowedHosts"],
      Context = data
    };
  }
  
  /// <summary>
  /// 获取用户信息
  /// </summary>
  /// <returns></returns>
  [HttpGet]
  [Route("GetUsersList")]
  public ApiResult GetUsersList()
  {
    var data = _userService.GetUsersR2();
    
    return new ApiResult()
    {
      Success = true,
      Message = "成功",
      Code = "0000",
      Context = data
    };
  }
}